 <?php include('../conn.php');
 


 
if(isset($_GET['tdno'])){

$tdno=$_GET['tdno'];
$tranid=$_GET['tranid'];

if($tdno!='')
{
$qTDCH="SELECT trndetid,tranid,`Bkng Date` Bkng_Date,`ID Number` ID_Number,`Pax Name`Pax_Name, `Ticket Number` Ticket_Number,PNR, 
Sector,`Travel Date` Travel_Date,Basic,Tax,Admincharges,Amount FROM transactiondetails   where tranid='$tranid' and trndetid='$tdno'  ";
//echo $qTDCH; 

$tdQ=mysql_fetch_array(mysql_query($qTDCH)); 
if($tdQ)	
{  //if($tdQ)	

?>
<table width="1254" border="1" bordercolor="#666666" class="des">
 <tr>
  <td bgcolor="#fff" colspan="15" align="center"><br>
    <I><font color="#666666" size="5">Transaction Details against Master transaction No : <?php echo $tranid; ?></font></I>
    <br></td>
  </tr>
  
  
  
  <tr>
   <td width="55" bgcolor="#EBE9E9"><span class="style4"><strong>T.D. No</strong></span></td>
  <td width="121" bgcolor="#EBE9E9"><span class="style4"><strong>Booking Date</strong></span></td>
    <td width="167" bgcolor="#EBE9E9"><span class="style4"><strong>ID Number</strong> </span></td>
   
    <td width="80" bgcolor="#EBE9E9"><span class="style4"><strong>PAX</strong></span></td>
    <td width="117" bgcolor="#EBE9E9"><span class="style4"><strong>Ticket Number </strong></span></td>
    <td width="71" bgcolor="#EBE9E9"><span class="style4"><strong>PNR</strong></span></td>
    <td width="76" bgcolor="#EBE9E9"><span class="style4"><strong>SECTOR</strong></span></td>
    <td width="108" bgcolor="#EBE9E9"><span class="style4"><strong>Travel Date</strong></span></td>
    <td width="83" bgcolor="#EBE9E9"><span class="style4"><strong>Basic</strong></span></td>
	<td width="64" bgcolor="#EBE9E9"><span class="style4"><strong>TAX</strong></span></td>
	<td width="97" bgcolor="#EBE9E9"><span class="style4"><strong>Admin Charge</strong> </span></td>
	<td width="93" bgcolor="#EBE9E9"><span class="style4"><strong>Amount</strong></span></td>
	<td width="17" bgcolor="#EBE9E9">&nbsp;</td>
	<td width="17" bgcolor="#EBE9E9">&nbsp;</td>
  </tr>
  
  <?php

 $color='#F9F8F8';
 
  ?>
 
  <tr bgcolor="<?php echo $color; ?>">
     <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$tdQ[trndetid] "?></td>
    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$tdQ[Bkng_Date] "?></td>
	
    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$tdQ[ID_Number]"?></td>
    <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$tdQ[Pax_Name]"?></td>
	  <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$tdQ[Ticket_Number]"?></td>
	  
    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$tdQ[PNR]"?></td>
	 <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$tdQ[Sector]"?></td>
	  <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$tdQ[Travel_Date]"?></td>
	   <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$tdQ[Basic]"?></td>
	    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$tdQ[Tax]"?></td>
		 <td   style="border-right:  solid 1px #CCCCCC"><?php echo "$tdQ[Admincharges]"?></td>
		  <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$tdQ[Amount]"?></td>
		 
 
   
    <td  style="border-right:  solid 1px #CCCCCC"><form method="post" action="ViewTransactionDetails.php">
	<input name="submit"   type="image" src="images/edit2.png" width="15" height="15"  />
	<input name="flag" type="hidden" value="<?php echo 1;?>" />
	<input name="tranid" type="hidden" value="<?php echo $tranid;?>" />
		<input name="trndetid" type="hidden" value="<?php echo $tdQ['trndetid'];?>" />
	
	
	</form>		</td>
    <td  style="border-right:  solid 1px #CCCCCC"><form method="post" >
	<input name="submit"   type="image" src="images/del.png" width="15" height="15"  />
	<input name="flag" type="hidden" value="<?php echo 1;?>" />
	<input name="tranid" type="hidden" value="<?php echo $tdQ['trndetid'];?>" />
	
	
	</form></td>
  </tr>
 
 
   
   <tr bgcolor="#FFFFFF">
   <td colspan="14">&nbsp;</td>
   </tr>
</table><?php 
} //if($tdQ)	

else
echo "<font color='red'><I>No Transaction Details found Against transaction Master No $tranid</I></font>";


 } else {

$qTDCH="SELECT count(*) as c FROM transactiondetails   where tranid='$tranid'  ";
//echo $qTDCH; 

$tdQ=mysql_fetch_array(mysql_query($qTDCH)); 

if($tdQ['c']>0)
{ // if($tdQ['c']>0)
// paging first part
/*** Purpose : To display records by paging ***/
//Set the page size
$PageSize = 3;
$StartRow = 0;

//Set the page no
if(empty($_GET['PageNo'])){
    if($StartRow == 0){
        $PageNo = $StartRow + 1;
    }
}else{
    $PageNo = $_GET['PageNo'];
    $StartRow = ($PageNo - 1) * $PageSize;
}

//Set the counter start
if($PageNo % $PageSize == 0){
    $CounterStart = $PageNo - ($PageSize - 1);
}else{
    $CounterStart = $PageNo - ($PageNo % $PageSize) + 1;
}

//Counter End
$CounterEnd = $CounterStart + ($PageSize - 1);

 // paging first part
 

?>
<table width="1254" border="1" bordercolor="#666666" class="des">
	 <tr>
  <td bgcolor="#fff" colspan="15" align="center"><br>
    <I><font color="#666666" size="5">Transaction Details against Master transaction No : <?php echo $tranid; ?></font></I>
    <br></td>
  </tr>
  
  
  <tr>
   <td width="45" bgcolor="#EBE9E9"><span class="style4"><strong>T.D NO</strong></span></td>
  <td width="131" bgcolor="#EBE9E9"><span class="style4"><strong>Booking Date</strong></span></td>
    <td width="167" bgcolor="#EBE9E9"><span class="style4"><strong>ID Number</strong> </span></td>
   
    <td width="80" bgcolor="#EBE9E9"><span class="style4"><strong>PAX</strong></span></td>
    <td width="117" bgcolor="#EBE9E9"><span class="style4"><strong>Ticket Number </strong></span></td>
    <td width="71" bgcolor="#EBE9E9"><span class="style4"><strong>PNR</strong></span></td>
    <td width="76" bgcolor="#EBE9E9"><span class="style4"><strong>SECTOR</strong></span></td>
    <td width="108" bgcolor="#EBE9E9"><span class="style4"><strong>Travel Date</strong></span></td>
    <td width="83" bgcolor="#EBE9E9"><span class="style4"><strong>Basic</strong></span></td>
	<td width="64" bgcolor="#EBE9E9"><span class="style4"><strong>TAX</strong></span></td>
	<td width="97" bgcolor="#EBE9E9"><span class="style4"><strong>Admin Charge</strong> </span></td>
	<td width="93" bgcolor="#EBE9E9"><span class="style4"><strong>Amount</strong></span></td>
	<td width="17" bgcolor="#EBE9E9">&nbsp;</td>
	<td width="17" bgcolor="#EBE9E9">&nbsp;</td>
  </tr>
  
  <?php
  
 $TRecord = mysql_query(" SELECT trndetid,tranid,`Bkng Date` Bkng_Date,`ID Number` ID_Number,`Pax Name`Pax_Name, `Ticket Number` Ticket_Number,PNR, 
Sector,`Travel Date` Travel_Date,Basic,Tax,Admincharges,Amount FROM transactiondetails ");

 $q1 = mysql_query(" SELECT trndetid,tranid,`Bkng Date` Bkng_Date,`ID Number` ID_Number,`Pax Name`Pax_Name, `Ticket Number` Ticket_Number,PNR, 
Sector,`Travel Date` Travel_Date,Basic,Tax,Admincharges,Amount FROM transactiondetails where tranid='$tranid'  ORDER BY trndetid asc  LIMIT $StartRow,$PageSize");

 //Total of record
 $RecordCount = mysql_num_rows($TRecord);

 //Set Maximum Page
 $MaxPage = $RecordCount % $PageSize;
 if($RecordCount % $PageSize == 0){
    $MaxPage = $RecordCount / $PageSize;
 }else{
    $MaxPage = ceil($RecordCount / $PageSize);
 }
?>
        <?php //print "$RecordCount record(s) founds - You are at page $PageNo  of $MaxPage" ?>	
		  <?php
$i = 1;
while ($r1 = mysql_fetch_array($q1, MYSQL_NUM)) {
    $bil = $i + ($PageNo-1)*$PageSize;
?>

  <?php 
  

 
 if($i%2==0)
 $color='#E7F8FB';
 else 
 $color='#F9F8F8';
 
  ?>
 
  <tr bgcolor="<?php echo $color; ?>">
     <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[0] "?></td>
    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[2] "?></td>
	
    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[3]"?></td>
    <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$r1[4]"?></td>
    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[5]"?></td>
	 <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[6]"?></td>
	  <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[7]"?></td>
	   <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$r1[8]"?></td>
	    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[9]"?></td>
		 <td   style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[10]"?></td>
		  <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$r1[11]"?></td>
		   <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$r1[12]"?></td>
 
   
    <td  style="border-right:  solid 1px #CCCCCC"><form method="post" action="ViewTransactionDetails.php">
	<input name="submit"   type="image" src="images/edit2.png" width="15" height="15"  />
	<input name="flag" type="hidden" value="<?php echo 1;?>" />
	<input name="tranid" type="hidden" value="<?php echo $tranid;?>" />
		<input name="trndetid" type="hidden" value="<?php echo $r1['0'];?>" />
	
	
	</form>		</td>
    <td  style="border-right:  solid 1px #CCCCCC"><form method="post" >
	<input name="submit"   type="image" src="images/del.png" width="15" height="15"  />
	<input name="flag" type="hidden" value="<?php echo 1;?>" />
	<input name="tranid" type="hidden" value="<?php echo $r1['0'];?>" />
	
	
	</form></td>
  </tr>
 
  <?php  
  
   $i++; } ?>
   
   <tr bgcolor="#FFFFFF">
   <td colspan="14"><?php
        //Print First & Previous Link is necessary
        if($CounterStart != 1){
            $PrevStart = $CounterStart - 1;
            print "<a href=ViewTransactionDetails.php?PageNo=1&tranid=$tranid><font color='black'>First</font> </a>: ";
            print "<a href=ViewTransactionDetails.php?PageNo=$PrevStart&tranid=$tranid><font color='black'>Previous </font></a>";
        }
        print " [ ";
        $c = 0;

        //Print Page No
        for($c=$CounterStart;$c<=$CounterEnd;$c++){
            if($c < $MaxPage){
                if($c == $PageNo){
                    if($c % $PageSize == 0){
                        print "$c ";
                    }else{
                        print "$c ,";
                    }
                }elseif($c % $PageSize == 0){
                    echo "<a href=ViewTransactionDetails.php?PageNo=$c&tranid=$tranid><font color='black'>$c</font></a> ";
                }else{
                    echo "<a href=ViewTransactionDetails.php?PageNo=$c&tranid=$tranid><font color='black'>$c</font></a> ,";
                }//END IF
            }else{
                if($PageNo == $MaxPage){
                    print "$c ";
                    break;
                }else{
                    echo "<a href=ViewTransactionDetails.php?PageNo=$c&tranid=$tranid><font color='black'>$c</font></a> ";
                    break;
                }//END IF
            }//END IF
       }//NEXT

      echo "] ";

      if($CounterEnd < $MaxPage){
          $NextPage = $CounterEnd + 1;
          echo "<a href=ViewTransactionDetails.php?PageNo=$NextPage&tranid=$tranid><font color='black'>Next</font></a>";
      }
      
      //Print Last link if necessary
      if($CounterEnd < $MaxPage){
       $LastRec = $RecordCount % $PageSize;
        if($LastRec == 0){
            $LastStartRecord = $RecordCount - $PageSize;
        }
        else{
            $LastStartRecord = $RecordCount - $LastRec;
        }

        print " : ";
        echo "<a href=ViewTransactionDetails.php?PageNo=$MaxPage&tranid=$tranid><font color='black'>Last</font></a>";
        }
      ?></td>
   </tr>
</table>

<?php 
} // if($tdQ['c']>0)

else
echo "<font color='red'><I>No Transaction Details found Against transaction Master No $tranid</I></font>";


} ?>

<?php  } ?>